Allow an array of matches in the pattern matching rules#24
Open
x-m-el wants to merge 10 commits into
Open
Conversation
this greatly reduces the size of delta messages in stacks with large data changes.
this tries to optimize filtering and match detection in two ways: - by grouping on match pattern: this means we only do detection and filtering once for a given match pattern (takes the pattern and sendMatchesOnly into account) - by doing matching before origin filter, since the latter seems more costly
this is not the prettiest of solutions, but it does achieve the same thing. bonus is it only happens once on startup
it's mentioned in the expressjs best practices (and elsewhere) that process.env should be used sparingly: | If you need to write environment-specific code, you can check the value of NODE_ENV with process.env.NODE_ENV. Be aware that checking the value of any environment variable incurs a performance penalty, and so should be done sparingly. https://expressjs.com/th/advanced/best-practice-performance.html#set-node_env-to-production it seems this is because process.env is a getter that processes the ENV array each time
matches in the patern matching rulesmatches in the pattern matching rules
This allows setting multiple matches (a combination of subject, predicate and object) for one definition. The same can be achieved by creating multiple definitions with the same callback/options and a different single match pattern. Using an object (instead of array) for a `match` is still allowed: this is backwards compatible. This also changes two aspects of how deltas are sent through: When a delta matches multiple patterns (matches), it will send the same change sets multiple times to the same url, for every match that is in the rules. When using an array for `match`es, the change set will only be sent once. When using in conjunction with `sendMatchesOnly`, all patterns matching those defined in `match`es will be sent in one change set together. When not using an array for `match`es, multiple change sets with "one type of match" each would be sent to the url.
fe49625 to
3981024
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows setting multiple matches (a combination of subject, predicate and object) for one definition. The same can be achieved by creating multiple definitions with the same callback/options and a different single match pattern.
Using an object (instead of array) for a
matchis still allowed: this is backwards compatible.This also changes two aspects of how deltas are sent through:
When a delta matches multiple patterns (matches), it will send the same change sets multiple times to the same url, for every match that is in the rules.
When using an array for
matches, the change set will only be sent once.When using in conjunction with
sendMatchesOnly, all patterns matching those defined inmatches will be sent in one change set together. When not using an array formatches, multiple change sets with "one type of match" each would be sent to the url.Note: for ease of merging, this is build further upon #21, which is a PR for a fork. So this PR includes those commits as well (the base can't be set to the fork).
This code change could easily be changed to a change on master, as it changes a function that was only moved in #21.
The actual changes for this PR is the last commit.